home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / emac16as.arc / EMACS.ASM < prev    next >
Assembly Source File  |  1990-04-01  |  44KB  |  2,208 lines

  1. ;History:1327,1
  2. ;Mon Mar 05 12:11:46 1990 Remove #(lk) and #(lr)
  3. ;Thu Feb 22 23:39:34 1990 make buffer-modified be a bitmap.
  4. ;Thu Feb 22 23:33:37 1990 add logical operators: || (or), && (and), ^^ (xor).
  5. ;Wed Feb 21 12:42:50 1990 auto_save should only be called on "real" input.
  6. ;Sat Oct 14 23:44:54 1989 in #(ex), if the stdout and stderr names are equal,redirect them to the same handle.
  7. ;Tue Sep 19 23:03:53 1989 Add support for Desqview.
  8. ;Sat Aug 19 23:25:22 1989 add ec_prim -- execution counts.
  9. ;Wed May 03 22:12:32 1989 Use a variable for the default bell pitch.
  10. ;Wed May 03 21:10:16 1989 don't 'and' the background color with 7.
  11. ;Tue Mar 07 23:58:36 1989 add parameters to #(bl)
  12. ;Tue Mar 07 23:33:36 1989 background colors are only three bits -- and them with 7.
  13. ;Mon Jan 30 22:49:56 1989 Add support for multiple colors.
  14. ;10-02-88 20:50:38 add a buffer for mouse clicks.
  15. ;10-01-88 14:50:07 make #(lv,ms) return four numbers.
  16. ;09-23-88 20:37:28 clean up auto_save
  17. ;09-18-88 23:13:35 Add "string index", si_prim
  18. ;09-18-88 12:32:52 use lowercase pathnames in #(lv,cd).
  19. ;09-12-88 23:40:00 if the buffer-modified flag is 2, then the buffer is read-only.
  20. ;09-10-88 05:44:35 Use bl instead of num_screen_cols in announce().
  21. ;09-10-88 05:40:21 try returning / when they try to find it.
  22. ;08-16-88 00:23:20 change auto save so it only count changes to a file.
  23. ;07-24-88 23:25:20 Put the third argument to #(an) *after* the cursor.
  24. ;07-19-88 00:17:27 Create 'li' primitive.
  25. ;05-15-88 19:58:02 Remove reference to non-existent init_memory [kdb]
  26. ;05-07-88 22:07:45 if stdout and stderr are redirected, don't bother swapping screens.
  27. ;04-17-88 22:47:53 add the ex redirect code.
  28. ;04-03-88 23:28:39 move the version number into another file.
  29. ;04-01-88 22:47:59 add tc variable.
  30. ;03-30-88 21:22:49 move xlat_to_mark to memory.asm
  31. ;03-30-88 20:48:45 add tr_prim
  32. ;03-27-88 19:47:54 add store_firstline and store_lastline
  33. ;03-26-88 15:53:35 put the variables in alphabetic order.
  34. ;03-26-88 14:24:12 expand the ?v_prim symbols to the two letter symbols.
  35. ;03-26-88 10:02:03 get rid of old single-letter variables.
  36. ;03-26-88 10:01:52 add auto-save counter
  37. ;03-23-88 23:56:09 Add variables 'fo' and 'bo' for original colors.
  38. ;03-13-88 12:27:10 remove #(ef)
  39. ;03-10-88 22:41:26 add #(l?)
  40. ;12-13-87 21:17:22 
  41. ;11-26-87 11:45:11 fix goofyness in it_prim.
  42. ;09-09-87 00:49:51 after fixing redisp for the column redisplay bug, bump the version.
  43. ;07-15-87 22:10:51 up the version letter because I gave a copy to Pat.
  44. ;07-13-87 23:11:23 remove xyputch.
  45. ;07-13-87 23:00:03 move things around between files.
  46. ;07-10-87 23:09:06 add #(lv,vn) - version number.
  47. ;07-10-87 22:54:07 fix the problem with #(lv,xx) where xx is not a variable.
  48. ;07-10-87 00:23:10 remove trailing blank from #(sv,cd,...)
  49. ;07-10-87 00:17:28 add #(sv,cd,...)
  50. ;07-08-87 21:37:15 put a trailing \ on 'cd' variable.
  51. ;07-08-87 21:01:05 create the 'cd' variable.
  52. ;07-05-87 14:16:38 make complete paths in ff_prim an assembly-time option.
  53. ;07-05-87 14:02:28 compute the prefix length in ff_prim properly.
  54. ;07-05-87 11:55:54 Return full pathname and lowercase in ff_prim.
  55. test_prims    equ    0
  56.     page    ,132
  57.  
  58.     .xlist
  59.     include    memory.def
  60.     include    mint.def
  61.     include    findfile.def
  62.  
  63. data    segment    byte public
  64.  
  65.     extrn    version_number: byte, version_number_len: abs
  66.  
  67. ;the following externs are defined in 'mintprim'
  68.     extrn    read_errors: word
  69.     extrn    write_errors: word
  70.     extrn    data_bottop: word
  71.     extrn    data_topbot: word
  72.  
  73. ;the following externs are defined in 'mintscan'
  74.     extrn    fbgn: word, fend: word
  75.     extrn    next_ids: word
  76.  
  77. ;the following externs are defined in the computer-dependent file.
  78.     extrn    max_screen_line: byte
  79.     extrn    num_screen_cols: word
  80.     extrn    computer_name: byte
  81.     extrn    computer_name_len: abs
  82.  
  83.     public    filename, filename2
  84. filename    db    64 dup(?)
  85. filename2    db    64 dup(?)
  86.  
  87. rename_error    db    'Rename error'
  88. rename_error_len    equ    $-rename_error
  89.  
  90. speller_txt    db    'Speller'
  91. speller_txt_len    equ    $-speller_txt
  92.  
  93.     extrn    next_redisp_line: word
  94.  
  95.     public    standard_ids
  96. standard_ids    db    '#(d,#(g))',0
  97.  
  98. nokbd_ids    db    '#(k)#(d,#(g))',0
  99. auto_ids    db    '#(Fauto-save)',0
  100.  
  101. auto_save_limit    dw    0
  102. auto_save_cntr    dw    0
  103.  
  104. byte_ptr    label    byte
  105.  
  106. color_list    label    byte
  107. fore_color    db    7
  108. back_color    db    0
  109. control_color    db    2
  110. whitespc_color    db    7
  111.  
  112. bell_pitch    dw    2000
  113.  
  114. ex_stdin    dw    ?        ;-1 if we're not redirecting.
  115. ex_stdout    dw    ?        ;-1 if we're not redirecting.
  116. ex_stderr    dw    ?        ;-1 if we're not redirecting.
  117.     extrn    swap_screen_flag: word    ;=1 if we should swap screens.
  118.  
  119.     extrn    tab_size: word
  120.     extrn    fore_original: byte
  121.     extrn    back_original: byte
  122.  
  123. variable_table    label    byte
  124.     db    'as'            ;Auto Save
  125.     db    'bc'            ;Background Color
  126.     db    'bl'            ;Bot Line
  127.     db    'bo'            ;Background Original
  128.     db    'bs'            ;Bot Scroll
  129.     db    'cc'            ;Control Color
  130.     db    'cd'            ;Current Directory
  131.     db    'cl'            ;Line Number
  132.     db    'cn'            ;Computer Name
  133.     db    'cs'            ;Column on Screen
  134.     db    'cw'            ;Current Window
  135.     db    'bp'            ;Bell Pitch
  136.     db    'fc'            ;Foreground Color
  137.     db    'fo'            ;Foreground Original
  138.     db    'im'            ;Inverse Mark
  139.     db    'is'            ;Inhibit Snow
  140.     db    'lc'            ;Lefthand Column
  141.     db    'mb'            ;Modified Buffer
  142.     db    'ms'            ;Mint Space
  143.     db    'nl'            ;Number of Lines
  144.     db    'ow'            ;Other Window
  145.     db    'pb'            ;Percent of Buffer
  146.     db    'rc'            ;Rightmost Column
  147.     db    'rs'            ;Row on Screen
  148.     db    'tc'            ;Tab Columns
  149.     db    'tl'            ;Top Line
  150.     db    'ts'            ;Top Scroll
  151.     db    'vn'            ;Version Number
  152.     db    'wc'            ;Whitespace Color
  153.     db    'ws'            ;Whitespace Showing
  154. variable_count    equ    ($-variable_table)/2
  155.  
  156. lv_prim_table    label    word
  157.     dw    lv_prim_as
  158.     dw    lv_prim_bc
  159.     dw    lv_prim_bl
  160.     dw    lv_prim_bo
  161.     dw    lv_prim_bs
  162.     dw    lv_prim_cc
  163.     dw    lv_prim_cd
  164.     dw    lv_prim_cl
  165.     dw    lv_prim_cn
  166.     dw    lv_prim_cs
  167.     dw    lv_prim_cw
  168.     dw    lv_prim_bp
  169.     dw    lv_prim_fc
  170.     dw    lv_prim_fo
  171.     dw    lv_prim_im
  172.     dw    lv_prim_is
  173.     dw    lv_prim_lc
  174.     dw    lv_prim_mb
  175.     dw    lv_prim_ms
  176.     dw    lv_prim_nl
  177.     dw    lv_prim_ow
  178.     dw    lv_prim_pb
  179.     dw    lv_prim_rc
  180.     dw    lv_prim_rs
  181.     dw    lv_prim_tc
  182.     dw    lv_prim_tl
  183.     dw    lv_prim_ts
  184.     dw    lv_prim_vn
  185.     dw    lv_prim_wc
  186.     dw    lv_prim_ws
  187.  
  188. sv_prim_table    label    word
  189.     dw    sv_prim_as
  190.     dw    sv_prim_bc
  191.     dw    sv_prim_bl
  192.     dw    sv_prim_bo
  193.     dw    sv_prim_bs
  194.     dw    sv_prim_cc
  195.     dw    sv_prim_cd
  196.     dw    sv_prim_cl
  197.     dw    sv_prim_cn
  198.     dw    sv_prim_cs
  199.     dw    sv_prim_cw
  200.     dw    sv_prim_bp
  201.     dw    sv_prim_fc
  202.     dw    sv_prim_fo
  203.     dw    sv_prim_im
  204.     dw    sv_prim_is
  205.     dw    sv_prim_lc
  206.     dw    sv_prim_mb
  207.     dw    sv_prim_ms
  208.     dw    sv_prim_nl
  209.     dw    sv_prim_ow
  210.     dw    sv_prim_pb
  211.     dw    sv_prim_rc
  212.     dw    sv_prim_rs
  213.     dw    sv_prim_tc
  214.     dw    sv_prim_tl
  215.     dw    sv_prim_ts
  216.     dw    sv_prim_vn
  217.     dw    sv_prim_wc
  218.     dw    sv_prim_ws
  219.  
  220.     extrn    stackp: byte
  221.  
  222.     public    trace_handle
  223. trace_handle    dw    -1
  224.  
  225. sa_jump        dw    ?
  226. sa_n_jump    dw    ?
  227.  
  228. mouse_buffer    dw    0        ;mouse button buffer.
  229.  
  230.   if timing
  231.     public    counting
  232. counting    db    0
  233.     extrn    counts: word
  234.     extrn    times: word
  235.   endif
  236.  
  237. data    ends
  238.  
  239.  
  240. code    segment    byte public
  241.     assume    cs:code, ds:data, es:data
  242.  
  243.     extrn    set_screen_color: near
  244.  
  245.     extrn    redisplay: near        ;ax=line to leave the cursor on.
  246.  
  247.     extrn    buffer_free: near
  248.     extrn    read_firstline: near
  249.     extrn    read_lastline: near
  250.     extrn    store_firstline: near
  251.     extrn    store_lastline: near
  252.     extrn    read_newrow: near
  253.     extrn    read_linesbefore: near
  254.     extrn    read_linecount: near
  255.     extrn    read_buffer_modified: near
  256.     extrn    store_buffer_modified: near
  257.     extrn    read_ibm_cga: near
  258.     extrn    store_ibm_cga: near
  259.     extrn    read_inverse_mark: near
  260.     extrn    store_inverse_mark: near
  261.  
  262.     extrn    read_showblanks: near
  263.     extrn    store_showblanks: near
  264.  
  265.     extrn    read_top_percent: near
  266.     extrn    read_bot_percent: near
  267.     extrn    store_top_percent: near
  268.     extrn    store_bot_percent: near
  269.  
  270.     extrn    read_other_window: near
  271.     extrn    read_current_window: near
  272.     extrn    store_other_window: near
  273.     extrn    store_current_window: near
  274.  
  275.     extrn    chrout: near        ;al=char to overwrite to screen.
  276.  
  277.     extrn    paint_screen: near    ;sets entire screen to be repainted.
  278.  
  279.     extrn    paint_window: near    ;causes the current buffer to be shown in the current window.
  280.  
  281.     extrn    insert_string: near    ;si,cx describe the string.
  282.  
  283.     extrn    buffer_allocate: near    ;entry: cx=buffer number to select,
  284.                     ;  cx=0 to create new buffer.
  285.                     ;  ax=0 for read/write buffer.
  286.                     ;exit: ax=new buffer number if enough
  287.                     ;  memory, ax=0 otherwise.
  288.     extrn    read_mark: near        ;entry: al=mark to read to.
  289.                     ;exit: es:si, cx describing string.
  290.  
  291.     extrn    del_to_mark: near    ;entry: al=mark to delete to.
  292.  
  293.     extrn    set_mark: near        ;entry: al=dest mark, ah=source mark.
  294.  
  295.     extrn    goto_mark: near        ;entry: al=mark to go to.
  296.  
  297.     extrn    xlat_to_mark: near    ;entry: al=mark to translate to.
  298.                     ;  es:bx = translate table,
  299.                     ;  dx = length of translate table.
  300.  
  301.     extrn    stack_marks: near    ;entry: ax>0 to create temp marks,
  302.                     ;  ax=0 to delete temp marks,
  303.                     ;  ax<0 to create perm marks and delete
  304.                     ;  all temp marks.
  305.  
  306.     extrn    compute_cursor: near    ;exit with dx=column (0..65535)
  307.  
  308.     extrn    set_column: near    ;entry: ax=desired column
  309.  
  310.     extrn    set_line: near        ;entry: ax=desired line.
  311.  
  312.     extrn    read_firstcolumn: near    ;get the left hand column.
  313.  
  314.     extrn    store_firstcolumn: near    ;set the left hand column.
  315.  
  316.     extrn    ring_the_bell: near
  317.  
  318.  
  319. ;the following extrns are in the computer-dependent file
  320.     extrn    xychrout: near
  321.     extrn    clear_count: near
  322.     extrn    position_cursor: near
  323.     extrn    check_for_key: near
  324.     extrn    give_up_slice: near
  325.  
  326. ;the following extrns are in 'files'
  327.     extrn    read_file: near
  328.     extrn    write_file: near
  329.  
  330. ;the following extrns are in 'search'
  331.     extrn    regexp_pat: near
  332.     extrn    set_pattern: near
  333.     extrn    search: near
  334.  
  335. ;the following extrns are in 'mintscan'
  336.     extrn    nomem: near
  337.  
  338. ;the following externs are in 'pick'
  339.     extrn    pick_on: near
  340.     extrn    pick_off: near
  341.     extrn    check_pick: near
  342.     extrn    get_pick_values: near
  343.  
  344.  
  345.     public    init_ids
  346. init_ids:
  347.     mov    sp,offset stackp
  348.     call    check_for_key        ;use the standard ids only if kbd ready.
  349.     jnz    init_ids_1
  350.     mov    ax,offset nokbd_ids
  351. init_ids_2:
  352.     cmp    next_ids,offset standard_ids    ;only use a different one if
  353.     jne    init_ids_1            ;we're at the standard ids.
  354.     mov    next_ids,ax
  355. init_ids_1:
  356.     jmp    init_ids_continue
  357.  
  358.     extrn    init_ids_continue: near
  359.  
  360.  
  361. write_protect:
  362.     call    read_buffer_modified    ;see if this buffer is read-only.
  363.     test    al,2
  364.     jne    write_protect_1        ;yes - leave immediately.
  365.     ret
  366. write_protect_1:
  367.     pop    ax            ;discard our return address.
  368.     jmp    return_null
  369.  
  370.  
  371. auto_save:
  372. ;preserve bp.
  373.     mov    ax,auto_save_cntr    ;is the counter already at zero?
  374.     or    ax,ax            ;is the counter already at zero?
  375.     je    auto_save_1        ;yes - don't decrement it.
  376.     dec    ax            ;time to auto-save?
  377.     jne    auto_save_1        ;no.
  378.     mov    ax,auto_save_limit    ;yes - reset the counter.
  379.     mov    next_ids,offset auto_ids
  380. auto_save_1:
  381.     mov    auto_save_cntr,ax
  382.     ret
  383.  
  384.  
  385.     if    test_prims
  386.  
  387. ;test primitive.  fills memory to the max.  strictly for testing only.
  388. ts_prim:
  389.     di_points_fbgn
  390.     mov    cx,data_topbot
  391.     sub    cx,di
  392.     dec    cx
  393.     push    cx
  394.     mov    al,' '
  395.     rep    stosb
  396.     pop    cx
  397.     jmp    return_sicx
  398.  
  399.  
  400. formSeg    segment    public
  401. ;the following externs are defined in 'mintform'
  402.     extrn    formhash: word
  403. formSeg    ends
  404.  
  405. ;dump formhash.  strictly for testing only.
  406. tt_prim:
  407.     mov    cx,256
  408.     di_points_fbgn
  409.     chk_room_cnt
  410.     mov    si,offset formhash
  411. tt_prim_1:
  412.     test    cx,3fh
  413.     jne    tt_prim_4
  414.     mov    ax,LINENEW
  415.     stosw
  416. tt_prim_4:
  417.     mov    dx,0
  418.     lodsw
  419.     mov    bx,ax
  420. tt_prim_2:
  421.     cmp    bx,NIL        ;at end of list yet?
  422.     je    tt_prim_3
  423.     mov    bx,[bx].hash_link
  424.     inc    dx
  425.     jmp    tt_prim_2
  426. tt_prim_3:
  427.     mov    ax,dx        ;get the count
  428.     add    al,'0'        ;convert to ascii (cheaply)
  429.     stosb
  430.     loop    tt_prim_1
  431.     jmp    return_tos
  432.  
  433.     endif
  434.  
  435.   if timing
  436. ec_prim:
  437.     call    getarg1
  438.     jcxz    ec_prim_0
  439.  
  440. ;zero out the old times.
  441.     xor    bx,bx
  442.     mov    cx,function_name_length
  443. ec_prim_8:
  444.     mov    counts[bx],0
  445.     mov    times[bx],0
  446.     add    bx,2
  447.     loop    ec_prim_8
  448.  
  449. ;now say that we're counting, and init the timer chip.
  450.     mov    counting,1
  451.     mov    al,34h
  452.     out    43h,al
  453.     jmp    short ec_prim_3
  454. ec_prim_3:
  455.     mov    al,0
  456.     out    40h,al
  457.     jmp    short ec_prim_4
  458. ec_prim_4:
  459.     mov    al,0
  460.     out    40h,al
  461.     jmp    return_null
  462.  
  463. ec_prim_0:
  464.     xor    bx,bx
  465.     mov    si,offset function_name_table
  466.     di_points_fbgn
  467.     mov    cx,function_name_length * (2 + 1 + 5 + 2)
  468.     chk_room_cnt
  469.     mov    cx,function_name_length
  470. ec_prim_1:
  471.     movsw
  472.     mov    al,' '
  473.     stosb
  474.  
  475.     push    bx
  476.     push    cx
  477.  
  478.     push    times[bx]
  479.  
  480.     mov    ax,counts[bx]
  481.     mov    cx,5            ;always use 5 digits.
  482.     mov    bx,10
  483.     call    put_number
  484.  
  485.     pop    ax
  486.  
  487.     cmp    counting,0        ;are we counting?
  488.     je    ec_prim_7
  489.  
  490.     mov    byte ptr [di],' '
  491.     inc    di
  492.  
  493.     mov    cx,5            ;always use 5 digits.
  494.     mov    bx,10
  495.     call    put_number
  496.  
  497. ec_prim_7:
  498.     pop    cx
  499.     pop    bx
  500.  
  501.     mov    times[bx],0        ;zero the counters.
  502.     mov    counts[bx],0
  503.  
  504.     mov    al,CR
  505.     stosb
  506.     mov    al,LF
  507.     stosb
  508.     add    bx,2
  509.     loop    ec_prim_1
  510.  
  511.     cmp    counting,0        ;restore the counter only if we were
  512.     je    ec_prim_2        ;  counting.
  513.  
  514.     mov    al,36h
  515.     out    43h,al
  516.     jmp    short ec_prim_5
  517. ec_prim_5:
  518.     mov    al,0
  519.     out    40h,al
  520.     jmp    short ec_prim_6
  521. ec_prim_6:
  522.     mov    al,0
  523.     out    40h,al
  524.  
  525. ec_prim_2:
  526.     mov    counting,0
  527.     jmp    return_tos
  528.   endif
  529.  
  530.  
  531. ;redisplay.
  532. rd_prim:
  533.     call    getarg1
  534.     jcxz    rd_prim_1
  535.     call    paint_screen        ;paint,
  536.     call    paint_window
  537.     jmp    short rd_prim_3        ; always redisplay
  538. rd_prim_1:
  539.     call    check_for_key        ;redisplay only if no key waiting.
  540.     jnz    rd_prim_2
  541. rd_prim_3:
  542.     call    redisplay
  543. rd_prim_2:
  544.     jmp    return_null
  545.  
  546.  
  547. ;overwrite the screen.
  548. ow_prim:
  549.     call    getarg1
  550.     jcxz    ow_prim_2
  551. ow_prim_1:
  552.     lodsb
  553.     xor    ah,ah
  554.     call    chrout
  555.     push    si
  556.     push    cx
  557.     pop    cx
  558.     pop    si
  559.     loop    ow_prim_1
  560. ow_prim_2:
  561.     jmp    return_null
  562.  
  563.  
  564.     extrn    get_math: near
  565.     extrn    gotoxy: near
  566.  
  567. ;gotoxy
  568. xy_prim:
  569.     call    get_math
  570.     mov    dh,al
  571.     mov    dl,bl
  572.     call    gotoxy
  573.     jmp    return_null
  574.  
  575.  
  576. ;announce a string
  577. an_prim:
  578.     mov    bx,num_screen_cols    ;end of the line.
  579.     mov    cx,2            ;if the second arg is non-null,
  580.     mov    dh,0            ;start in this column
  581.     call    getarg
  582.     jcxz    an_prim_1
  583.     call    read_lastline        ;  put the announcement after the current window.
  584.     inc    al
  585.     mov    dl,al
  586.     call    announce1
  587.     call    clear_count        ;clear to the end of the annunciator.
  588.     jmp    return_null
  589. an_prim_1:
  590.     mov    dl,max_screen_line    ;get the row.
  591.     inc    dl
  592.     inc    dl            ;put our announcement after it.
  593.     call    announce1        ;announce the left part.
  594.     call    position_cursor        ;  put the cursor at the end of the string
  595.     mov    cx,3            ;now announce the right part.
  596.     call    announce
  597.     call    clear_count        ;clear to the end of the annunciator.
  598.     jmp    return_null
  599.  
  600.  
  601. announce1:
  602.     mov    cx,1
  603. announce:
  604. ;given an argument in cx, print it at row=dl, column=dh.
  605.     call    getarg
  606.     jcxz    announce_2        ;if null, we';re done.
  607. announce_1:
  608.     cmp    dh,bl            ;end of the line.
  609.     jae    announce_2        ;if we hit end of line, we're done.
  610.     lodsb                ;get a character.
  611.     mov    ah,0
  612.     call    xychrout
  613.     inc    dh
  614.     loop    announce_1
  615. announce_2:
  616.     ret
  617.  
  618.  
  619. ;insert a string.
  620. is_prim:
  621.     call    write_protect
  622.     call    getarg1
  623.     call    insert_string
  624.     jc    is_prim_1        ;go if we can't insert it.
  625.     jmp    return_null
  626. is_prim_1:
  627.     mov    cx,2
  628.     jmp    return_arg
  629.  
  630.  
  631.     extrn    get_mint_space: near
  632.  
  633. lv_prim:
  634. ;load variable
  635.     mov    bx,offset lv_prim_table
  636.     call    parse_variable
  637.     di_points_fbgn
  638.     jmp    word ptr [bx]
  639.  
  640. lv_prim_cd:
  641.     mov    cx,64+3            ;we need at most 64 plus 'a:\'.
  642.     chk_room_cnt
  643.     mov    ah,19h            ;get the current drive.
  644.     int    21h
  645.     mov    dl,al
  646.     inc    dl
  647.     add    al,'a'
  648.     stosb
  649.     mov    ax,':' + '\'*256
  650.     stosw
  651.  
  652.     mov    si,di            ;get the directory here.
  653.     mov    ah,47h            ;get current directory.
  654.     int    21h
  655. lv_prim_cd_1:                ;find the terminating null.
  656.     lodsb
  657.     call    to_lower        ;lowercase the filename.
  658.     mov    [si-1],al
  659.     or    al,al
  660.     jne    lv_prim_cd_1
  661.     dec    si
  662.     xchg    di,si            ;di should point to the null.
  663.  
  664.     cmp    si,di            ;are we in a subdirectory?
  665.     je    lv_prim_cd_2
  666.     mov    al,'\'            ;yes - store a trailing backslash.
  667.     stosb
  668. lv_prim_cd_2:
  669.     jmp    return_tos
  670.  
  671.  
  672. lv_prim_vn:
  673.     mov    si,offset version_number
  674.     mov    cx,version_number_len
  675.     chk_room_cnt
  676.     rep    movsb
  677.     jmp    return_tos
  678.  
  679.  
  680. lv_prim_cn:
  681.     mov    si,offset computer_name
  682.     mov    cx,computer_name_len
  683.     chk_room_cnt
  684.     rep    movsb
  685.     jmp    return_tos
  686.  
  687.  
  688. lv_prim_im:
  689.     call    read_inverse_mark
  690.     stosb
  691.     jmp    return_tos
  692.  
  693. lv_prim_pb:
  694.     call    read_linecount
  695.     inc    ax
  696.     push    ax
  697.     call    read_linesbefore
  698.     inc    ax
  699.     mov    dx,100
  700.     mul    dx
  701.     pop    cx
  702.     div    cx
  703.     jmp    return_number
  704.  
  705. lv_prim_ms:
  706.     mov    cx,6*4
  707.     chk_room_cnt
  708.     call    get_mint_space
  709.     jmp    return_tos
  710.  
  711. lv_prim_bp:
  712.     mov    ax,bell_pitch
  713.     jmp    return_number
  714.  
  715. lv_prim_fc:
  716.     mov    ah,0
  717.     mov    al,fore_color
  718.     jmp    return_number
  719.  
  720. lv_prim_bc:
  721.     mov    ah,0
  722.     mov    al,back_color
  723.     jmp    return_number
  724.  
  725. lv_prim_cc:
  726.     mov    ah,0
  727.     mov    al,control_color
  728.     jmp    return_number
  729.  
  730. lv_prim_wc:
  731.     mov    ah,0
  732.     mov    al,whitespc_color
  733.     jmp    return_number
  734.  
  735. lv_prim_fo:
  736.     mov    ah,0
  737.     mov    al,fore_original
  738.     jmp    return_number
  739.  
  740. lv_prim_bo:
  741.     mov    ah,0
  742.     mov    al,back_original
  743.     jmp    return_number
  744.  
  745. lv_prim_ow:
  746.     call    read_other_window
  747.     jmp    return_number
  748.  
  749. lv_prim_cw:
  750.     call    read_current_window
  751.     jmp    return_number
  752.  
  753. lv_prim_ts:
  754.     call    read_top_percent
  755.     mov    ah,0
  756.     jmp    return_number
  757. lv_prim_bs:
  758.     call    read_bot_percent
  759.     mov    ah,0
  760.     jmp    return_number
  761. lv_prim_ws:
  762.     call    read_showblanks
  763.     inc    ax
  764.     jmp    return_number
  765. lv_prim_nl:
  766.     call    read_linecount
  767.     inc    ax
  768.     jmp    return_number
  769. lv_prim_rc:
  770.     mov    ax,num_screen_cols
  771.     inc    ax
  772.     jmp    return_number
  773. lv_prim_rs:
  774.     call    read_newrow
  775.     inc    ax
  776.     jmp    return_number
  777. lv_prim_cs:
  778.     call    compute_cursor
  779.     mov    ax,dx
  780.     inc    ax
  781.     jmp    return_number
  782. lv_prim_lc:
  783.     call    read_firstcolumn
  784.     inc    ax
  785.     jmp    return_number
  786. lv_prim_tc:
  787.     mov    ax,tab_size
  788.     inc    ax
  789.     jmp    return_number
  790. lv_prim_tl:
  791.     call    read_firstline
  792.     mov    ah,0
  793.     inc    ax
  794.     jmp    return_number
  795. lv_prim_bl:
  796.     call    read_lastline
  797.     mov    ah,0
  798.     inc    ax
  799.     jmp    return_number
  800. lv_prim_mb:
  801.     call    read_buffer_modified
  802.     mov    ah,0
  803.     jmp    return_number
  804. lv_prim_is:
  805.     call    read_ibm_cga
  806.     mov    ah,0
  807.     jmp    return_number
  808. lv_prim_as:
  809.     mov    ax,auto_save_limit
  810.     jmp    return_number
  811. lv_prim_cl:
  812.     call    read_linesbefore
  813.     inc    ax
  814.     jmp    return_number
  815.  
  816.  
  817. sv_prim:
  818. ;store variable
  819.     mov    bx,offset sv_prim_table
  820.     call    parse_variable
  821.     push    bx
  822.     mov    cx,2
  823.     call    get_decimal_arg
  824.     pop    bx
  825.     call    word ptr [bx]
  826.     jmp    return_null
  827.  
  828. sv_prim_bp:
  829.     mov    bell_pitch,ax
  830.     ret
  831.  
  832.  
  833. sv_prim_fc:
  834.     mov    fore_color,al
  835.     mov    si,offset color_list
  836.     call    set_screen_color
  837.     ret
  838.  
  839. sv_prim_bc:
  840.     mov    back_color,al
  841.     mov    si,offset color_list
  842.     call    set_screen_color
  843.     ret
  844.  
  845. sv_prim_cc:
  846.     mov    control_color,al
  847.     mov    si,offset color_list
  848.     call    set_screen_color
  849.     ret
  850.  
  851.  
  852. sv_prim_wc:
  853.     mov    whitespc_color,al
  854.     mov    si,offset color_list
  855.     call    set_screen_color
  856.     ret
  857.  
  858.  
  859. sv_prim_ow:
  860.     call    store_other_window
  861.     ret
  862.  
  863. sv_prim_cw:
  864.     call    store_current_window
  865.     ret
  866.  
  867. sv_prim_ts:
  868.     call    store_top_percent
  869.     ret
  870. sv_prim_bs:
  871.     call    store_bot_percent
  872.     ret
  873. sv_prim_ws:
  874.     call    store_showblanks    ;whitespace.
  875.     ret
  876. sv_prim_im:
  877.     mov    cx,2
  878.     call    getarg_mark
  879.     call    store_inverse_mark
  880.     ret
  881. sv_prim_cd:
  882.     mov    cx,2            ;get the "filename" into filename.
  883.     call    getarg_filename
  884.     mov    ax,[si]            ;get the first two chars.
  885.     or    al,al            ;do we have anything at all?
  886.     je    sv_prim_cd_1        ;no.
  887.     cmp    ah,':'            ;is the second char ':'?
  888.     jne    sv_prim_cd_2        ;no.
  889.     add    si,2            ;parse past these characters.
  890.     call    to_lower        ;convert the drive character to lowercase.
  891.     sub    al,'a'
  892.     mov    ah,0eh            ;select drive
  893.     mov    dl,al
  894.     int    21h
  895. sv_prim_cd_2:
  896.     mov    dx,si            ;save a copy and find the first null.
  897. sv_prim_cd_3:
  898.     lodsb
  899.     or    al,al
  900.     jne    sv_prim_cd_3
  901.     sub    si,2            ;make si -> last char of path.
  902.     cmp    si,dx            ;is this a one character subdir?
  903.     je    sv_prim_cd_4        ;yes - don't strip trailing slashes.
  904.     xor    al,al
  905.     xchg    al,[si]            ;store a null there.
  906.     cmp    al,'\'            ;was it a backslash?
  907.     je    sv_prim_cd_4        ;yes.
  908.     cmp    al,'/'            ;was it a slash?
  909.     je    sv_prim_cd_4        ;yes.
  910.     mov    [si],al            ;no - store the original char.
  911. sv_prim_cd_4:
  912.     mov    ah,3bh            ;change to this directory.
  913.     int    21h
  914. sv_prim_cd_1:
  915.     ret
  916.  
  917. sv_prim_tc:
  918.     cmp    ax,2
  919.     je    sv_prim_tc_1
  920.     cmp    ax,4
  921.     je    sv_prim_tc_1
  922.     cmp    ax,8
  923.     je    sv_prim_tc_1
  924.     cmp    ax,16
  925.     jne    sv_prim_tc_2
  926. sv_prim_tc_1:
  927.     dec    ax
  928.     mov    tab_size,ax
  929.     call    paint_screen
  930. sv_prim_tc_2:
  931.     ret
  932.  
  933. sv_prim_tl:
  934.     dec    ax
  935.     call    store_firstline
  936.     ret
  937.  
  938. sv_prim_bl:
  939.     dec    ax
  940.     call    store_lastline
  941.     ret
  942.  
  943. sv_prim_fo:
  944. sv_prim_bo:
  945. sv_prim_vn:
  946. sv_prim_cn:
  947. sv_prim_pb:
  948. sv_prim_ms:
  949. sv_prim_nl:
  950. sv_prim_rc:
  951.     ret
  952. sv_prim_rs:
  953.     mov    next_redisp_line,ax
  954.     ret
  955. sv_prim_cs:
  956.     call    set_column
  957.     ret
  958. sv_prim_lc:
  959.     dec    ax
  960.     call    store_firstcolumn
  961.     ret
  962. sv_prim_mb:
  963.     call    store_buffer_modified
  964.     ret
  965. sv_prim_is:
  966.     call    store_ibm_cga
  967.     ret
  968. sv_prim_as:
  969.     mov    auto_save_limit,ax
  970.     mov    auto_save_cntr,ax
  971.     ret
  972. sv_prim_cl:
  973.     call    set_line
  974.     ret
  975.  
  976.  
  977.  
  978.  
  979. parse_variable:
  980. ;parse a variable letter.
  981. ;return bx -> proper entry in the table pointed to by bx on entry.
  982. ;the default is at the end of the table.
  983.     call    getarg1
  984.     mov    ax,'l'            ;defaults to line
  985.     jcxz    parse_variable_1
  986.     lodsb
  987.     dec    cx
  988.     je    parse_variable_1
  989.     mov    ah,[si]
  990. parse_variable_1:
  991.     mov    di,offset variable_table
  992.     mov    cx,variable_count
  993.     repne    scasw
  994.     sub    cx,variable_count-1
  995.     neg    cx
  996.     shl    cx,1
  997.     add    bx,cx
  998.     ret
  999.  
  1000.  
  1001. pp_prim:
  1002.     di_points_fbgn
  1003.     mov    cx,11            ;make sure there's enough room.
  1004.     chk_room_cnt
  1005.     call    get_pick_values
  1006.     push    dx            ;save vertical
  1007.     mov    ax,cx
  1008.     mov    cx,0
  1009.     mov    bx,10
  1010.     call    put_number
  1011.     mov    al,','
  1012.     stosb
  1013.     pop    ax            ;pushed as dx
  1014.     jmp    return_number
  1015.  
  1016.  
  1017. sa_prim:
  1018.     mov    di,fend            ;make di point to some free memory.
  1019.     add    di,2
  1020.     mov    si,fbgn            ;point si at "sa".
  1021.     mov    si,[si]            ;point si at the first arg.
  1022.     mov    dx,0            ;count the arguments here.
  1023. sa_prim_1:
  1024.     cmp    si,[si]            ;are we pointing at fend?
  1025.     je    sa_prim_2
  1026.     mov    [di],si            ;save a pointer to the argument.
  1027.     add    di,2
  1028.     chk_room
  1029.     mov    si,[si]            ;make it point to next arg.
  1030.     inc    dx
  1031.     jmp    sa_prim_1
  1032. sa_prim_2:
  1033. ;dx=number of arguments.
  1034. ;fend+2->argument pointers.
  1035.  
  1036.     mov    bx,fend            ;make bx point to some free memory.
  1037.     add    bx,2
  1038.  
  1039.     mov    sa_jump,dx
  1040.     dec    dx
  1041.  
  1042. loop1:
  1043.     cmp    sa_jump,1        ;is JUMP > 1?
  1044.     jbe    sa_prim_4        ;no - sort complete
  1045.     shr    sa_jump,1        ;JUMP = JUMP DIV 2
  1046.  
  1047. loop2:
  1048.     mov    bp,1            ;set DONE = TRUE
  1049.     mov    ax,dx            ;get N
  1050.     sub    ax,sa_jump        ;compute N - JUMP
  1051.     mov    sa_n_jump,ax        ;store N - JUMP
  1052.     mov    cx,0
  1053.                     ;for J = 1 to N - JUMP DO
  1054. loop3:
  1055.     mov    si,bx
  1056.     add    si,cx            ;make si -> a[J]
  1057.     add    si,cx
  1058.     mov    di,si
  1059.     add    di,sa_jump        ;offset I by JUMP
  1060.     add    di,sa_jump
  1061.  
  1062.  
  1063.     push    cx
  1064.  
  1065.     push    si
  1066.     push    di
  1067.  
  1068.     mov    si,[si]            ;get the two arguments under consideration.
  1069.     mov    di,[di]
  1070.  
  1071.     mov    ax,[si]            ;compute length of this arg.
  1072.     sub    ax,si
  1073.     sub    ax,mark_overhead
  1074.     add    si,mark_overhead-1    ;make si=> text of argument.
  1075.  
  1076.     mov    cx,[di]            ;compute length of this arg.
  1077.     sub    cx,di
  1078.     sub    cx,mark_overhead
  1079.     add    di,mark_overhead-1    ;make si=> text of argument.
  1080.  
  1081.     cmp    ax,cx            ;if the first string is shorter,
  1082.     jb    sa_prim_8        ;  return if if they're equal.
  1083.                     ;second string is smaller.
  1084.     push    cx
  1085.     repe    cmpsb            ;compare the two strings
  1086.     pop    cx
  1087.     pop    di
  1088.     pop    si
  1089.     jb    sa_prim_5        ;go if they're in order already.
  1090.     ja    sa_prim_6        ;if they're not in order, swap them.
  1091.     cmp    ax,cx            ;were the strings equal?
  1092.     je    sa_prim_5        ;yes - don't swap them.
  1093.     jmp    short sa_prim_6
  1094.  
  1095. sa_prim_8:
  1096.     xchg    cx,ax            ;first string is smaller.
  1097.     repe    cmpsb            ;compare the two strings
  1098.     pop    di
  1099.     pop    si
  1100.     jbe    sa_prim_5        ;go if they're in order already.
  1101.  
  1102. sa_prim_6:
  1103.     mov    ax,[si]            ;swap them.
  1104.     xchg    ax,[di]
  1105.     mov    [si],ax
  1106.     mov    bp,0            ;set DONE = FALSE
  1107. sa_prim_5:
  1108.     pop    cx            ;get the counter back.
  1109.     inc    cx            ;bump the counter
  1110.     cmp    cx,sa_n_jump        ;is cx = N - JUMP?
  1111.     jbe    loop3            ;if cycle not complete, go again
  1112.     cmp    bp,0            ;is DONE = FALSE
  1113.     je    loop2            ;no, another cycle
  1114.     jmp    loop1            ;keep going until sort is complete
  1115.  
  1116. sa_prim_4:
  1117.     inc    dx            ;because we 'dec'ed it before.
  1118.     mov    bx,fend            ;make bx point to some free memory.
  1119.     add    bx,2
  1120.     mov    di,bx            ;compute the end of the table.
  1121.     add    di,dx
  1122.     add    di,dx
  1123.     push    di
  1124. sa_prim_7:
  1125.     mov    si,[bx]
  1126.     add    bx,2
  1127.     mov    cx,[si]            ;compute length of this arg.
  1128.     sub    cx,si
  1129.     sub    cx,mark_overhead
  1130.     add    si,mark_overhead-1    ;make si=> text of argument.
  1131.     inc    cx            ;include space for the comma.
  1132.     chk_room_cnt
  1133.     dec    cx
  1134.     rep    movsb
  1135.     mov    al,','            ;comma terminate the strings.
  1136.     stosb
  1137.  
  1138.     dec    dx            ;done with all of them?
  1139.     jne    sa_prim_7        ;no - do another.
  1140.  
  1141.     jmp    return_tos
  1142.  
  1143.  
  1144. bl_prim:
  1145.     call    get_decimal_arg1
  1146.     push    ax
  1147.     mov    cx,2
  1148.     call    get_decimal_arg
  1149.     mov    cx,ax
  1150.     pop    bx
  1151.     or    bx,bx            ;Do they want the default?
  1152.     jne    bl_prim_1        ;no.
  1153.     mov    bx,bell_pitch        ;yes.
  1154. bl_prim_1:
  1155.     call    ring_the_bell
  1156.     jmp    return_null
  1157.  
  1158.  
  1159. ;push/pop marks
  1160. pm_prim:
  1161.     call    get_decimal_arg1
  1162.     call    stack_marks
  1163.     jc    pm_prim_1
  1164.     jmp    return_null
  1165. pm_prim_1:
  1166.     mov    cx,2
  1167.     jmp    return_arg_active
  1168.  
  1169.  
  1170. ;set mark (to point)
  1171. sm_prim:
  1172.     mov    cx,2
  1173.     call    getarg_mark
  1174.     mov    al,'.'        ;if 2nd is missing, use '.'
  1175.     jcxz    sm_prim_1
  1176.     lodsb
  1177. sm_prim_1:
  1178.     mov    ah,al        ;get source mark
  1179.     push    ax        ;save source mark
  1180.     call    getarg_mark1
  1181.     pop    bx        ;pushed as ax
  1182.     mov    ah,bl        ;get dest mark
  1183.     call    set_mark
  1184.     jmp    return_null
  1185.  
  1186.  
  1187. ;set point (to marks)
  1188. sp_prim:
  1189.     mov    cx,1
  1190.     call    getarg
  1191.     jcxz    sp_prim_1
  1192. sp_prim_2:
  1193.     lodsb
  1194.     push    si
  1195.     push    cx
  1196.     call    goto_mark
  1197.     pop    cx
  1198.     pop    si
  1199.     loop    sp_prim_2
  1200. sp_prim_1:
  1201.     jmp    return_null
  1202.  
  1203.  
  1204. ;delete to mark
  1205. dm_prim:
  1206.     call    write_protect
  1207.     call    getarg1
  1208.     jcxz    dm_prim_1
  1209. dm_prim_2:
  1210.     lodsb
  1211.     push    si
  1212.     push    cx
  1213.     call    del_to_mark
  1214.     pop    cx
  1215.     pop    si
  1216.     loop    dm_prim_2
  1217. dm_prim_1:
  1218.     jmp    return_null
  1219.  
  1220.  
  1221. ;read to mark
  1222. rm_prim:
  1223.     call    getarg_mark1    ;get mark number to read from.
  1224.     call    read_mark    ;returns es:si, cx describing string.
  1225.     assume    ds:nothing
  1226.     di_points_fbgn
  1227. ;    chk_room_cnt
  1228.     mov    ax,es
  1229.     call    buffer_free    ;make sure that there's that much room.
  1230.     jc    rm_prim_1    ;if cy, there must be no room.
  1231.     rep    movsb        ;move the string.
  1232.     push    es        ;restore our ds.
  1233.     pop    ds
  1234.     jmp    return_tos
  1235. rm_prim_1:
  1236.     add    sp,2        ;conserve the stack.
  1237.     push    es        ;restore our ds.
  1238.     pop    ds
  1239.     assume    ds:data
  1240.     mov    cx,2
  1241.     jmp    return_arg_active
  1242.  
  1243.  
  1244. ;translate characters.
  1245. tr_prim:
  1246.     call    write_protect
  1247.     mov    cx,2        ;translate according to arg 2.
  1248.     call    getarg
  1249.     push    si
  1250.     push    cx
  1251.     call    getarg_mark1    ;get mark number to read from.
  1252.     pop    dx
  1253.     pop    bx
  1254.     call    xlat_to_mark
  1255.     jmp    return_null
  1256.  
  1257.  
  1258. ;count to mark
  1259. rc_prim:
  1260.     call    getarg_mark1    ;get mark number to read from.
  1261.     call    read_mark    ;returns ds:si, cx describing string.
  1262.     push    es        ;restore our ds.
  1263.     pop    ds
  1264.     mov    ax,cx
  1265.     di_points_fbgn
  1266.     jmp    return_number
  1267.  
  1268.  
  1269. ;spell check
  1270. sc_prim:
  1271.     push    ds
  1272.     xor    ax,ax
  1273.     mov    ds,ax
  1274.     lds    si,ds:[4*82h]        ;get the speller's interrupt.
  1275.     sub    si,speller_txt_len+2    ;backup past the string and version.
  1276.     mov    di,offset speller_txt
  1277.     mov    cx,speller_txt_len    ;see if the speller is installed.
  1278.     repe    cmpsb
  1279.     pop    ds
  1280.  
  1281.     mov    ax,-1            ;if no speller, return -1.
  1282.     jne    sc_prim_1        ;no speller.
  1283.  
  1284.     call    getarg1_filename
  1285.     push    si
  1286.     mov    cx,2
  1287.     call    get_decimal_arg
  1288.     mov    ah,al
  1289.     pop    si            ;get the pointer to the word.
  1290.     int    82h
  1291. sc_prim_1:
  1292.     di_points_fbgn
  1293.     jmp    return_number
  1294.  
  1295.  
  1296. ;mark before point #(mb,mark,before,after)
  1297. mb_prim:
  1298.     call    getarg_mark1
  1299.     call    read_mark
  1300.     push    es        ;restore our ds.
  1301.     pop    ds
  1302.     jc    mb_prim_1    ;go if point is before mark
  1303.     mov    cx,2
  1304.     jmp    return_arg
  1305. mb_prim_1:
  1306.     mov    cx,3
  1307.     jmp    return_arg
  1308.  
  1309.  
  1310.  
  1311. ;look pattern.  return arg 2 if bad pattern.
  1312. lp_prim:
  1313.     mov    cx,3            ;see if we should be regular or not.
  1314.     call    getarg
  1315.     mov    dx,cx            ;remember it.
  1316.     mov    cx,4            ;see if we should fold case or not.
  1317.     call    getarg
  1318.     mov    di,cx            ;remember it.
  1319.     call    getarg1
  1320.     call    set_pattern
  1321.     jc    lp_prim_1
  1322.     jmp    return_null
  1323. lp_prim_1:
  1324.     mov    cx,2
  1325.     jmp    return_arg_active
  1326.  
  1327.  
  1328. ;look for a string.  return arg 5 if found, arg 6 if not.
  1329. lt_prim:
  1330.     call    getarg_mark1
  1331.     push    ax
  1332.     mov    cx,2
  1333.     call    getarg_mark
  1334.     push    ax
  1335.     mov    cx,3
  1336.     call    getarg_mark
  1337.     push    ax
  1338.     mov    cx,4
  1339.     call    getarg_mark
  1340.     mov    dl,al        ;set arg 4 (last)
  1341.     pop    ax        ;restore arg 3 (first)
  1342.     mov    dh,al
  1343.     pop    cx        ;restore arg 2 (end) pushed as ax.
  1344.     pop    ax        ;restore arg 1 (start)
  1345.     mov    ch,al
  1346.     call    search
  1347.     mov    cx,5        ;if we found it, return arg 5.
  1348.     jnc    lt_prim_1
  1349.     mov    cx,6        ;else return arg 6.
  1350. lt_prim_1:
  1351.     jmp    return_arg
  1352.  
  1353.  
  1354. ;find the first and next occurrences of a file.
  1355. ff_prim:
  1356.     mov    dx,offset filename2
  1357.     mov    ah,1ah
  1358.     int    21h
  1359.     call    getarg1_filename
  1360.     mov    dx,si            ;remember the filename for find_first.
  1361.  
  1362.     di_points_fend
  1363.     mov    ax,[si]
  1364.     cmp    ah,':'            ;does this filename have a drive?
  1365.     jne    ff_prim_9        ;no.
  1366.     mov    ax,[si+2]        ;yes - skip it.
  1367. ff_prim_9:
  1368.     cmp    ax,'/'            ;are they referring to root?
  1369.     je    ff_prim_a
  1370.     cmp    ax,'\'
  1371.     jne    ff_prim_b
  1372. ff_prim_a:
  1373.     mov    cx,5
  1374.     chk_room_cnt
  1375. ff_prim_8:
  1376.     lodsb
  1377.     cmp    al,'/'
  1378.     jne    ff_prim_c
  1379.     mov    al,'\'
  1380. ff_prim_c:
  1381.     stosb
  1382.     or    al,al
  1383.     jne    ff_prim_8
  1384.     dec    di
  1385.  
  1386.     mov    cx,2            ;copy the separator argument.
  1387.     call    getarg
  1388.     chk_room_cnt
  1389.     rep    movsb
  1390.  
  1391.     jmp    return_tos
  1392.  
  1393. ff_prim_b:
  1394.     mov    ah,4eh            ;find first matching file
  1395.     mov    cx,10h            ;find subdirs, too.
  1396. ff_prim_1:
  1397.     int    21h            ;find first or find next.
  1398.     jnc    ff_prim_2        ;more files...
  1399.     jmp    return_tos
  1400. ff_prim_2:
  1401.  
  1402.     mov    si,offset filename2.find_buf_name
  1403.     mov    ah,0
  1404. ff_prim_3:
  1405.     lodsb
  1406.     or    al,al
  1407.     je    ff_prim_4
  1408.     cmp    al,'.'            ;remember if we got a '.'.
  1409.     jne    ff_prim_6
  1410.     inc    ah
  1411. ff_prim_6:
  1412.     call    to_lower
  1413.     chk_room
  1414.     stosb
  1415.     jmp    ff_prim_3
  1416. ff_prim_4:
  1417.  
  1418.     test    filename2.find_buf_attr,10h    ;is this a subdir?
  1419.     je    ff_prim_5        ;no.
  1420.     mov    al,'\'            ;yes- store a trailing backslash.
  1421.     chk_room
  1422.     stosb
  1423.     jmp    short ff_prim_7        ;don't consider storing '.'.
  1424. ff_prim_5:
  1425.     or    ah,ah            ;did we find a '.'?
  1426.     jne    ff_prim_7
  1427.     mov    al,'.'            ;no - store a trailing '.'.
  1428.     stosb
  1429. ff_prim_7:
  1430.  
  1431.     mov    cx,2            ;copy the separator argument.
  1432.     call    getarg
  1433.     chk_room_cnt
  1434.     rep    movsb
  1435.  
  1436.     mov    ah,4fh            ;find next.
  1437.     jmp    ff_prim_1
  1438.  
  1439.  
  1440. to_lower:
  1441.     cmp    al,'A'            ;uppercase?
  1442.     jb    to_lower_1
  1443.     cmp    al,'Z'
  1444.     ja    to_lower_1
  1445.     add    al,'a'-'A'        ;use uppercase.
  1446. to_lower_1:
  1447.     ret
  1448.  
  1449.  
  1450. ;rename a file.
  1451. rn_prim:
  1452.     call    getarg1_filename
  1453.     mov    cx,2
  1454.     call    getarg
  1455.     mov    di,offset filename2
  1456.     rep    movsb
  1457.     xor    al,al
  1458.     stosb
  1459.     mov    dx,offset filename
  1460.     mov    di,offset filename2
  1461.     mov    ah,56h            ;rename file
  1462.     int    21h
  1463.     jnc    rn_prim_1
  1464.     mov    si,offset rename_error
  1465.     mov    cx,rename_error_len
  1466.     jmp    return_sicx
  1467. rn_prim_1:
  1468.     jmp    return_null
  1469.  
  1470.  
  1471. ;delete a file.
  1472. de_prim:
  1473.     call    getarg1_filename
  1474.     mov    dx,si
  1475.     mov    ah,41h            ;delete file
  1476.     int    21h
  1477.     jnc    de_prim_1
  1478.     mov    al,2
  1479.     mov    bx,offset read_errors
  1480.     jmp    return_string
  1481. de_prim_1:
  1482.     jmp    return_null
  1483.  
  1484.  
  1485. ;read a file
  1486. rf_prim:
  1487.     call    write_protect
  1488.     call    getarg1_filename
  1489.     call    read_file
  1490.     mov    bx,offset read_errors
  1491.     jmp    return_string
  1492.  
  1493.  
  1494. ;write a file.
  1495. wf_prim:
  1496.     call    getarg1_filename
  1497.     push    si            ;preserve the pointer to the filename.
  1498.     mov    cx,2
  1499.     call    getarg_mark
  1500.     pop    si
  1501.     call    write_file
  1502.     mov    bx,offset write_errors
  1503.     jmp    return_string
  1504.  
  1505.  
  1506. ;allocate a buffer
  1507. ba_prim:
  1508.     call    get_decimal_arg1
  1509.     push    ax
  1510.     mov    cx,2
  1511.     call    getarg
  1512.     mov    ax,cx
  1513.     pop    cx            ;pushed as ax.
  1514.     call    buffer_allocate
  1515.     di_points_fbgn
  1516.     jmp    return_number
  1517.  
  1518.  
  1519. ;insert from a buffer
  1520. ;#(bi,buffer number,mark,yes,no)
  1521. bi_prim:
  1522.     call    write_protect
  1523.     call    get_decimal_arg1    ;get the buffer number.
  1524.     push    ax
  1525.     mov    cx,2            ;get the mark.
  1526.     call    getarg_mark
  1527.     pop    cx
  1528.     call    buffer_insert
  1529.     jc    bi_prim_1        ;go if we can't insert it.
  1530.     mov    cx,3
  1531.     jmp    return_arg
  1532. bi_prim_1:
  1533.     mov    cx,4
  1534.     jmp    return_arg
  1535.  
  1536.  
  1537. ao_prim:
  1538.     call    getarg1        ;get the first argument
  1539.     mov    dx,cx        ;save size of first argument
  1540.     mov    di,si        ;save pointer to first argument
  1541.     mov    cx,2        ;get second argument
  1542.     call    getarg
  1543.     cmp    cx,dx        ;second shorter than first?
  1544.     jb    ao_prim_2    ;yes - use second's length.
  1545.     mov    cx,dx        ;no - use first's length.
  1546.     repe    cmpsb        ;strings alphabetically ordered?
  1547.     jb    ao_prim_4    ;no, return 4th.
  1548.     jmp    short ao_prim_3
  1549. ao_prim_2:
  1550.     repe    cmpsb        ;strings alphabetically ordered?
  1551.     jbe    ao_prim_4    ;no, return 4th.
  1552. ao_prim_3:
  1553.     mov    cx,3
  1554.     jmp    return_arg
  1555. ao_prim_4:
  1556.     mov    cx,4
  1557.     jmp    return_arg
  1558.  
  1559.  
  1560. it_prim:
  1561. ;check for key, timed.
  1562.     call    get_decimal_arg1
  1563.     mov    bp,ax            ;save the wait time.
  1564.     or    ax,ax            ;are they really waiting for a char?
  1565.     je    it_prim_0        ;go if not.
  1566.     call    auto_save
  1567. it_prim_0:
  1568.  
  1569.     call    check_for_key        ;character waiting?
  1570.     jne    it_prim_1        ;yes - don't turn the pick on.
  1571.     call    pick_on
  1572.     call    input_timed
  1573.     push    ax            ;preserve the key value.
  1574.     call    pick_off
  1575.     pop    ax
  1576.     jmp    short it_prim_2
  1577. it_prim_1:
  1578.     call    input_timed
  1579. it_prim_2:
  1580.     call    decode_key        ;no - change the key into a string.
  1581.     di_points_fbgn
  1582. it_prim_3:
  1583.     lodsb
  1584.     or    al,al
  1585.     je    it_prim_4
  1586.     chk_room
  1587.     stosb
  1588.     jmp    it_prim_3
  1589. it_prim_4:
  1590.     jmp    return_tos
  1591.  
  1592.  
  1593. input_timed:
  1594.     xor    ax,ax            ;check the mouse buffer first.
  1595.     xchg    ax,mouse_buffer
  1596.     or    ax,ax
  1597.     jne    input_timed_5        ;got one - see if we should restuff it.
  1598.  
  1599.     xor    si,si            ;si is the elapsed time.
  1600.     mov    ah,2ch            ;get the current hundreths.
  1601.     int    21h
  1602.     mov    bl,dl
  1603. input_timed_1:
  1604.     call    check_for_key        ;character waiting?
  1605.     jne    input_timed_2        ;yes - return it.
  1606.     call    check_pick        ;pick waiting?
  1607.     jne    input_timed_5        ;yes - return it.
  1608.     call    give_up_slice
  1609.     mov    ah,2ch            ;gtime
  1610.     int    21h
  1611.     mov    al,dl            ;subtract the new time from the old.
  1612.     sub    al,bl
  1613.     mov    bl,dl            ;update the time in bl.
  1614.     cbw
  1615.     jns    input_timed_4        ;go if it's positive.
  1616.     add    ax,100            ;make it positive.
  1617. input_timed_4:
  1618.     add    si,ax            ;add in to the current time.
  1619.     cmp    si,bp            ;time to timeout yet?
  1620.     jb    input_timed_1        ;no.
  1621.     mov    ax,255            ;yes - timeout.
  1622.     jmp    short input_timed_3
  1623. input_timed_5:
  1624.     or    bp,bp            ;original wait time.
  1625.     jnz    input_timed_3        ;if non zero wait, we're inputting it.
  1626.     mov    mouse_buffer,ax        ;store the mouse button in a buffer.
  1627.     jmp    short input_timed_3
  1628. input_timed_2:
  1629.     or    bp,bp            ;original wait time.
  1630.     jz    input_timed_3        ;if zero wait, we're just checking.
  1631.     call    get_key_value
  1632. input_timed_3:
  1633.     ret
  1634.  
  1635.  
  1636. bc_prim:
  1637.     mov    cx,2        ;get 'from' argument.
  1638.     call    getarg
  1639.     mov    dl,'a'        ;default to ASCII
  1640.     jcxz    bc_prim_1
  1641.     mov    dl,[si]        ;get from type.
  1642. bc_prim_1:
  1643.     mov    cx,3        ;get 'to' argument.
  1644.     call    getarg
  1645.     mov    dh,'d'        ;default to decimal
  1646.     jcxz    bc_prim_2
  1647.     mov    dh,[si]
  1648. bc_prim_2:
  1649.     call    getarg1
  1650.     call    bc_prim_base    ;get the source base.
  1651.     or    bx,bx        ;ASCII?
  1652.     jnz    bc_prim_4    ;no.
  1653.     jcxz    bc_prim_6
  1654.     lodsb
  1655.     mov    ah,0
  1656.     jmp    bc_prim_3
  1657. bc_prim_6:
  1658.     mov    ax,-1        ;if ASCII, and null argument, use -1.
  1659.     jmp    bc_prim_3
  1660. bc_prim_4:
  1661.     push    dx        ;preserve dx.
  1662.     call    get_number
  1663.     pop    dx
  1664. bc_prim_3:
  1665. ;we now have the number in ax.
  1666.     mov    dl,dh
  1667.     call    bc_prim_base
  1668.     di_points_fbgn
  1669.     or    bx,bx
  1670.     jnz    bc_prim_5
  1671.     stosb
  1672.     jmp    return_tos
  1673. bc_prim_5:
  1674.     mov    cx,0        ;use only as many digits as are needed.
  1675.     call    put_number
  1676.     jmp    return_tos
  1677.  
  1678.  
  1679. ;private subroutine, used only bc_prim.
  1680. bc_prim_base:
  1681. ;enter with dl=base character.
  1682. ;exit with bx=base if number; bx=0 if ASCII.
  1683.     or    dl,20h        ;convert UPPER case to lower case.
  1684.     cmp    dl,'d'
  1685.     jne    bc_prim_base_1
  1686.     mov    bx,10
  1687.     ret
  1688. bc_prim_base_1:
  1689.     cmp    dl,'o'
  1690.     jne    bc_prim_base_2
  1691.     mov    bx,8
  1692.     ret
  1693. bc_prim_base_2:
  1694.     cmp    dl,'h'
  1695.     jne    bc_prim_base_3
  1696.     mov    bx,16
  1697.     ret
  1698. bc_prim_base_3:
  1699.     cmp    dl,'c'
  1700.     jne    bc_prim_base_4
  1701.     mov    bx,0
  1702.     ret
  1703. bc_prim_base_4:
  1704.     cmp    dl,'a'        ;a alias character.
  1705.     jne    bc_prim_base_5
  1706.     mov    bx,0
  1707.     ret
  1708. bc_prim_base_5:
  1709.     cmp    dl,'b'
  1710.     jne    bc_prim_base_6
  1711.     mov    bx,2
  1712.     ret
  1713. bc_prim_base_6:
  1714.     ret
  1715.  
  1716.  
  1717. getarg_mark1:
  1718.     mov    cx,1
  1719. getarg_mark:
  1720. ;enter with cx=arg number.
  1721. ;exit with al=mark, cx=arg size, si->arg.
  1722.     call    getarg
  1723.     mov    al,0        ;use null if no string specified.
  1724.     jcxz    getarg_mark_1
  1725.     mov    al,[si]        ;get the first character
  1726. getarg_mark_1:
  1727.     ret
  1728.  
  1729.  
  1730.     public    trace_result
  1731. trace_result:
  1732. ;enter with si->, cx=count of returning result of a primitive call.
  1733. ;doesn't modify si or cx.
  1734.     push    bx
  1735.     push    cx
  1736.     push    si
  1737.     mov    bx,trace_handle
  1738.     or    bx,bx
  1739.     js    trace_result_3
  1740.     mov    al,'{'
  1741.     call    printchar
  1742.     jcxz    trace_result_1
  1743. trace_result_2:
  1744.     lodsb
  1745.     call    printchar
  1746.     loop    trace_result_2
  1747. trace_result_1:
  1748.     mov    al,'}'
  1749.     call    printchar
  1750.     mov    al,CR
  1751.     call    printchar
  1752.     mov    al,LF
  1753.     call    printchar
  1754.     mov    ah,7
  1755.     int    21h
  1756. trace_result_3:
  1757.     pop    si
  1758.     pop    cx
  1759.     pop    bx
  1760.     ret
  1761.  
  1762.  
  1763. neutral_marker    equ    3
  1764.  
  1765.     public    trace_invoke
  1766. trace_invoke:
  1767. ;enter with bx->fbgn, al=function type (active or neutral)
  1768.     push    bx
  1769.     push    dx
  1770.     push    di
  1771.     mov    di,bx
  1772.     mov    bx,trace_handle
  1773.     or    bx,bx
  1774.     js    trace_result_3
  1775.     cmp    al,neutral_marker
  1776.     jne    trace_invoke_1
  1777.     mov    al,"#"
  1778.     call    printchar
  1779. trace_invoke_1:
  1780.     mov    al,"#"
  1781.     call    printchar
  1782.     mov    al,"("
  1783.     call    printchar
  1784. trace_invoke_3:
  1785.     mov    si,di
  1786.     mov    di,[di]
  1787.     cmp    si,di        ;at end?
  1788.     je    trace_invoke_2    ;yes.
  1789.     mov    cx,di
  1790.     sub    cx,si
  1791.     sub    cx,mark_overhead    ;remove overhead.
  1792.     add    si,mark_overhead-1        ;skip past overhead.
  1793.     jcxz    trace_invoke_5
  1794. trace_invoke_4:
  1795.     lodsb
  1796.     call    printchar
  1797.     loop    trace_invoke_4
  1798. trace_invoke_5:
  1799.     cmp    di,[di]            ;last argument?
  1800.     je    trace_invoke_3        ;yes - don't print comma.
  1801.     mov    al,","
  1802.     call    printchar
  1803.     jmp    trace_invoke_3
  1804. trace_invoke_2:
  1805.     mov    al,")"
  1806.     call    printchar
  1807.     pop    di
  1808.     pop    dx
  1809.     pop    bx
  1810. trace_invoke_6:
  1811.     ret
  1812.  
  1813.  
  1814. printchar:
  1815.     mov    dl,al
  1816.     mov    ah,6
  1817.     int    21h
  1818.     ret
  1819.  
  1820.  
  1821. redirect:
  1822. ;enter with bx = device to redirect (0..2).
  1823. ;exit with ax = new flag for this device.
  1824.     mov    cx,bx            ;get the filename.
  1825.     add    cx,3
  1826.     call    getarg_filename
  1827.     je    redirect_1        ;no filename - don't redirect.
  1828.  
  1829.     mov    ah,45h            ;make a copy of handle in bx
  1830.     int    21h            ;  into ax.
  1831.  
  1832.     push    ax            ;remember the old handle.
  1833.     mov    ah,3eh            ;close the original handle.
  1834.     int    21h
  1835.     mov    ax,3d00h        ;open for reading.
  1836.     cmp    bx,0            ;redirecting from stdin?
  1837.     je    redirect_2
  1838.     mov    ah,3ch            ;no - we have to create it.
  1839.     xor    cx,cx
  1840. redirect_2:
  1841.     mov    dx,si            ;point to the filename.
  1842.     int    21h            ;either open or create.
  1843.     jc    redirect_3        ;go if we failed to open it.
  1844.     pop    ax            ;get the old handle back.
  1845.     ret
  1846. redirect_3:
  1847.     mov    cx,bx            ;get the original handle (now closed).
  1848.     pop    bx            ;get the copy of the original handle.
  1849.     mov    ah,46h            ;copy the bx handle to cx.
  1850.     int    21h
  1851.     mov    ah,3eh            ;now close the copy.
  1852.     int    21h
  1853. redirect_1:
  1854.     mov    ax,-1            ;say that there is no file open.
  1855.     ret
  1856.  
  1857.  
  1858. unredirect:
  1859. ;enter with bx = stdxxx file number, cx = handle to restore.
  1860.     cmp    cx,-1
  1861.     je    unredirect_1
  1862.  
  1863.     mov    ah,3eh            ;close stdxxx file.
  1864.     int    21h
  1865.  
  1866.     xchg    bx,cx            ;force the original handle back.
  1867.     mov    ah,46h
  1868.     int    21h
  1869.  
  1870.     mov    ah,3eh            ;close the copy.
  1871.     int    21h
  1872. unredirect_1:
  1873.     ret
  1874.  
  1875.  
  1876. ex_prim:
  1877.     mov    bx,0
  1878.     call    redirect
  1879.     mov    ex_stdin,ax
  1880.  
  1881.     mov    bx,1
  1882.     call    redirect
  1883.     mov    ex_stdout,ax
  1884.  
  1885.     mov    cx,4
  1886.     call    getarg            ;get the fourth argument
  1887.     mov    dx,cx            ;save size of fourth argument
  1888.     mov    di,si            ;save pointer to fourth argument
  1889.     mov    cx,5            ;get fifth argument
  1890.     call    getarg
  1891.     jcxz    ex_prim_2        ;if the fifth argument is empty, we're done.
  1892.     cmp    cx,dx            ;lengths equal?
  1893.     jne    ex_prim_2        ;no, separate redirect.
  1894.     repe    cmpsb            ;strings equal?
  1895.     jne    ex_prim_2        ;no, separate redirect.
  1896.  
  1897.     mov    bx,2
  1898.     mov    ah,45h            ;make a copy of handle in bx
  1899.     int    21h            ;  into ax.
  1900.     mov    ex_stderr,ax        ;remember it.
  1901.  
  1902.     mov    ah,3eh            ;close the original handle.
  1903.     int    21h
  1904.     mov    bx,1            ;now dup stdout into stderr.
  1905.     mov    ah,45h            ;make a copy of handle in bx
  1906.     int    21h            ;  into ax.
  1907.     jmp    short ex_prim_3
  1908.  
  1909. ex_prim_2:
  1910.     mov    bx,2
  1911.     call    redirect
  1912.     mov    ex_stderr,ax
  1913. ex_prim_3:
  1914.  
  1915.     push    swap_screen_flag
  1916.     mov    ax,ex_stdout
  1917.     or    ax,ex_stderr
  1918.     cmp    ax,-1            ;are we redirecting both of them?
  1919.     je    ex_prim_1        ;no.
  1920.     mov    swap_screen_flag,0    ;yes - don't swap screens.
  1921. ex_prim_1:
  1922.  
  1923.     call    getarg1_filename
  1924.     push    si
  1925.     mov    cx,2
  1926.     call    getarg
  1927.     pop    di
  1928.     call    execute_program
  1929.     pop    swap_screen_flag
  1930.  
  1931.     di_points_fbgn
  1932.  
  1933.     push    ax
  1934.     mov    bx,0
  1935.     mov    cx,ex_stdin
  1936.     call    unredirect
  1937.  
  1938.     mov    bx,1
  1939.     mov    cx,ex_stdout
  1940.     call    unredirect
  1941.  
  1942.     mov    bx,2
  1943.     mov    cx,ex_stderr
  1944.     call    unredirect
  1945.     pop    ax
  1946.  
  1947.     jmp    return_number
  1948.  
  1949.     extrn    execute_program: near
  1950.  
  1951.     extrn    get_key_value: near
  1952.     extrn    decode_key: near
  1953.     extrn    buffer_insert: near
  1954.  
  1955.     extrn    return_arg: near
  1956.     extrn    return_number: near
  1957.     extrn    return_null: near
  1958.     extrn    return_sicx: near
  1959.     extrn    return_tos: near
  1960.     extrn    return_arg_active: near
  1961.     extrn    return_string: near
  1962.     extrn    make_active: near
  1963.     extrn    getarg1_filename: near
  1964.     extrn    getarg_filename: near
  1965.     extrn    getarg1: near
  1966.     extrn    getarg: near
  1967.     extrn    get_decimal_arg1: near
  1968.     extrn    get_decimal_arg: near
  1969.     extrn    get_decimal: near
  1970.     extrn    get_number: near
  1971.     extrn    put_number: near
  1972.  
  1973. ;the following externs are defined in mintprim.asm
  1974.     extrn    dflt: near
  1975.     extrn    hl_prim: near
  1976.     extrn    eq_prim: near
  1977.     extrn    nc_prim: near
  1978.     extrn    db_prim: near
  1979.     extrn    ct_prim: near
  1980.     extrn    st_prim: near
  1981. ;forms
  1982.     extrn    ds_prim: near
  1983.     extrn    mp_prim: near
  1984.     extrn    gs_prim: near
  1985.     extrn    go_prim: near
  1986.     extrn    gn_prim: near
  1987.     extrn    rs_prim: near
  1988.     extrn    fm_prim: near
  1989.     extrn    ev_prim: near
  1990.     extrn    ls_prim: near
  1991.     extrn    es_prim: near
  1992.     extrn    sl_prim: near
  1993.     extrn    ll_prim: near
  1994.     extrn    nb_prim: near
  1995.     extrn    si_prim: near
  1996. ;math
  1997.     extrn    ad_prim: near
  1998.     extrn    su_prim: near
  1999.     extrn    ml_prim: near
  2000.     extrn    dv_prim: near
  2001.     extrn    md_prim: near
  2002.     extrn    and_prim: near
  2003.     extrn    or_prim: near
  2004.     extrn    xor_prim: near
  2005.     extrn    gr_prim: near
  2006.  
  2007.     public    ex_prim
  2008.     public    sc_prim
  2009.  
  2010.     public    rd_prim
  2011.     public    it_prim
  2012.  
  2013.     public    sa_prim
  2014.     public    is_prim
  2015.     public    bc_prim
  2016.     public    sv_prim
  2017.     public    lv_prim
  2018.     public    pp_prim
  2019.     public    bl_prim
  2020.     public    sm_prim
  2021.     public    sp_prim
  2022.     public    dm_prim
  2023.     public    rm_prim
  2024.     public    rc_prim
  2025.     public    mb_prim
  2026.     public    lp_prim
  2027.     public    rf_prim
  2028.     public    wf_prim
  2029.     public    an_prim
  2030.     public    ow_prim
  2031.     public    xy_prim
  2032.     public    pm_prim
  2033.     public    ba_prim
  2034.     public    bi_prim
  2035.     public    ff_prim
  2036.     public    rn_prim
  2037.     public    de_prim
  2038.   if timing
  2039.     public    ec_prim
  2040.   endif
  2041.   if test_prims
  2042.     public    ts_prim
  2043.     public    tt_prim
  2044.   endif
  2045.  
  2046.  
  2047. code    ends
  2048.  
  2049. data    segment    byte public
  2050.     public    function_name_table
  2051.     public    function_name_length
  2052.     public    function_address
  2053.  
  2054. function_name_table    label    word
  2055.     db    'rd'
  2056.     db    'it'
  2057.  
  2058.     db    '=='            ;equals
  2059.     db    'nc'            ;number of characters
  2060.     db    'ct'            ;convert time
  2061.     db    'a?'            ;alphabetic ordered?
  2062.     db    'sa'            ;sort ascending
  2063. ;forms
  2064.     db    'ds'            ;define string
  2065.     db    'mp'            ;make parameter
  2066.     db    'gs'            ;get string
  2067.     db    'go'            ;get one
  2068.     db    'gn'            ;get n
  2069.     db    'rs'            ;reset string
  2070.     db    'fm'            ;first match
  2071.     db    'ev'            ;read enviornment
  2072.     db    'ls'            ;list strings
  2073.     db    'es'            ;erase string
  2074.     db    'sl'            ;save library
  2075.     db    'll'            ;load library
  2076.     db    'n?'            ;name exists?
  2077.     db    'si'            ;string index
  2078. ;math
  2079.     db    '++'            ;add
  2080.     db    '--'            ;subtract
  2081.     db    '**'            ;multiply
  2082.     db    '//'            ;divide
  2083.     db    '%%'            ;modulus
  2084.     db    '||'            ;or
  2085.     db    '&&'            ;and
  2086.     db    '^^'            ;xor
  2087.     db    'g?'            ;numeric greater
  2088.  
  2089.     db    'is'            ;insert string
  2090.     db    'bc'            ;base conversion
  2091.     db    'sv'            ;set variable
  2092.     db    'lv'            ;load variable
  2093.     db    'pp'            ;pick position
  2094.     db    'bl'            ;bell
  2095.     db    'sm'            ;set mark
  2096.     db    'sp'            ;set point
  2097.     db    'dm'            ;del to mark
  2098.     db    'rm'            ;read to mark
  2099.     db    'rc'            ;read count
  2100.     db    'mb'            ;mark before
  2101.     db    'lp'            ;look pattern
  2102.     db    'l?'            ;look&test
  2103.     db    'rf'            ;read file
  2104.     db    'wf'            ;write file
  2105.     db    'an'            ;announce
  2106.     db    'ow'            ;overwrite
  2107.     db    'xy'            ;gotoxy
  2108.     db    'pm'            ;push/pop mark
  2109.     db    'ba'            ;buffer allocate
  2110.     db    'bi'            ;buffer insert
  2111.     db    'ff'            ;find files
  2112.     db    'rn'            ;rename file
  2113.     db    'de'            ;delete file
  2114.     db    'st'            ;syntax table
  2115.     db    'hl'            ;halt
  2116.     db    'db'            ;debug
  2117.     db    'tr'            ;translate
  2118.     db    'ex'            ;execute
  2119.     db    'sc'            ;spell check
  2120.   if timing
  2121.     db    'ec'
  2122.   endif
  2123.   if test_prims
  2124.     db    'ts'
  2125.     db    'tt'
  2126.   endif
  2127.  
  2128. function_name_length    equ ($-function_name_table)/2
  2129.  
  2130.     dw    dflt
  2131. function_address    label    word
  2132.     dw    rd_prim        ;redisplay
  2133.     dw    it_prim        ;input timed.
  2134.     dw    eq_prim
  2135.     dw    nc_prim
  2136.     dw    ct_prim
  2137.     dw    ao_prim
  2138.     dw    sa_prim
  2139. ;forms
  2140.     dw    ds_prim
  2141.     dw    mp_prim
  2142.     dw    gs_prim
  2143.     dw    go_prim
  2144.     dw    gn_prim
  2145.     dw    rs_prim
  2146.     dw    fm_prim
  2147.     dw    ev_prim
  2148.     dw    ls_prim
  2149.     dw    es_prim
  2150.     dw    sl_prim
  2151.     dw    ll_prim
  2152.     dw    nb_prim
  2153.     dw    si_prim
  2154. ;math
  2155.     dw    ad_prim
  2156.     dw    su_prim
  2157.     dw    ml_prim
  2158.     dw    dv_prim
  2159.     dw    md_prim
  2160.     dw    or_prim
  2161.     dw    and_prim
  2162.     dw    xor_prim
  2163.     dw    gr_prim
  2164.  
  2165.     dw    is_prim        ;insert string
  2166.     dw    bc_prim        ;base convert
  2167.     dw    sv_prim        ;set variable
  2168.     dw    lv_prim        ;load variable
  2169.     dw    pp_prim        ;pick position
  2170.     dw    bl_prim        ;bell
  2171.     dw    sm_prim        ;set mark
  2172.     dw    sp_prim        ;set point
  2173.     dw    dm_prim        ;delete to mark
  2174.     dw    rm_prim        ;read to mark
  2175.     dw    rc_prim        ;count to mark
  2176.     dw    mb_prim        ;mark before
  2177.     dw    lp_prim        ;look pattern
  2178.     dw    lt_prim        ;look&test
  2179.     dw    rf_prim        ;read file
  2180.     dw    wf_prim        ;write file
  2181.     dw    an_prim        ;announce
  2182.     dw    ow_prim        ;overwrite
  2183.     dw    xy_prim        ;gotoxy
  2184.     dw    pm_prim        ;push/pop mark
  2185.     dw    ba_prim        ;buffer allocate
  2186.     dw    bi_prim        ;buffer insert
  2187.     dw    ff_prim        ;find first/next
  2188.     dw    rn_prim        ;rename file
  2189.     dw    de_prim        ;delete file
  2190.     dw    st_prim        ;set the syntax table.
  2191.     dw    hl_prim
  2192.     dw    db_prim
  2193.     dw    tr_prim
  2194.     dw    ex_prim
  2195.     dw    sc_prim
  2196.   if timing
  2197.     dw    ec_prim
  2198.   endif
  2199.   if test_prims
  2200.     dw    ts_prim        ;test
  2201.     dw    tt_prim        ;test two
  2202.   endif
  2203.  
  2204. data    ends
  2205.  
  2206.  
  2207.     end
  2208.